<template>
    <el-dialog v-model="show" title="备注" width="25%" align-center @close="handleClose">
        <el-form ref="ruleFormRef" :model="ruleForm" label-width="auto" class="demo-ruleForm" status-icon>
            <el-form-item label="备注" prop="remark">
                <el-input v-model="ruleForm.remark" placeholder="请输入备注" />
            </el-form-item>
        </el-form>

        <template #footer>
            <div class="dialog-footer">
                <el-button type="primary" @click="handleSubmit" pinia>确 定</el-button>
            </div>
        </template>
    </el-dialog>

</template>

<script setup lang="ts">
import { updateQuotation } from '@/api/customerQuotation/index'

const props = defineProps(['visible', 'initList']);
const emits = defineEmits(['submit', 'close']);

const show = ref(false);


watch(() => props.visible, async (newValue) => {
    show.value = newValue
    if (newValue) {
        ruleForm.value.remark = props.initList.remark
    }
}, { deep: true });

const ruleForm = ref<any>({
    remark: '',
})
const handleSubmit = async () => {
    try {
        const { code } = await updateQuotation({
            id: props.initList.id,
            remark: ruleForm.value.remark
        })

        if (code === 200) {
            emits('submit', true);
            handleClose();
        }
    } catch (error) {

    }
}
const handleClose = () => {
    ruleForm.value.remark = false
    emits('close');
};

onMounted(() => {
})
</script>